import axios from "axios"
import qs from 'qs'

const http = axios.create({
    baseURL: '/api',
    withCredentials: true,
    transformRequest: (data) => {
        // console.log("请求转换")
        return qs.stringify(data, { indices: false });
    },
    transformResponse: (data) => {
        // console.log("响应转换")
        data = JSON.parse(data)
        return data;
    }

})

// http拦截请求
http.interceptors.request.use(request => {
    // console.log("拦截请求")
    return request;
})


// 拦截响应
http.interceptors.response.use(response => {
    // console.log("拦截响应")
    return response.data;
})


export default http





